#pragma once

#include "Grammar.h"
#include "Token.h"

#include <exception>

MAKE_PTR(CStatement);



class CStatement : public CToken
{
protected:

	typedef  int EvalType;

public:
    EvalType eval()
	{
		EvalType result = 0;
		if (this->preEval())
		{
			result = this->doEval();
		}
		
		this->postEval();

		return result;
	}

protected:

	EvalType virtual doEval()
	{
		throw std::exception("virtual function called in CStatement::doEval");
		return 0;
	}



	bool virtual preEval()
	{
		if (! GET_GRAMMAR()->getScope()->getExecute())
		{
			return false;
		}
		
		return true;
	}

	void virtual postEval()
	{
		return;
	}

};
